//
//  LSZAudioMusicCollectionViewCell.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/4/12.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZAudioMusicCollectionViewCell.h"

@implementation LSZAudioMusicCollectionViewCell
-(id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        self.labelNumber =[[UILabel alloc]init];
        self.labelNumber.textColor = titleColorLSZ;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelNumber font:14.5];
        [self addSubview:self.labelNumber];

        self.lableTitle = [[UILabel alloc]init];
        self.lableTitle.textColor = titleColorLSZ;
        [LSZSpecialPackaging setLabel_14_5_Size:self.lableTitle];
        [self addSubview:self.lableTitle];


        self.labelIntroduce = [[UILabel alloc]init];
        self.labelIntroduce.textColor = lightColor;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelIntroduce font:13];
        [self addSubview:self.labelIntroduce];

        self.imageViewHeadset = [[UIImageView alloc]init];
        self.imageViewHeadset.image = [UIImage imageNamed:@"耳机_次数"];
        [self addSubview:self.imageViewHeadset];

        self.labelPlaysNumber = [[UILabel alloc]init];
        self.labelPlaysNumber.textColor = lightColor;
        [LSZSpecialPackaging setLabelAdaptiveSize:self.labelPlaysNumber font:13];
        [self addSubview:self.labelPlaysNumber];


        self.butMove = [[UIButton alloc]init];
        [self addSubview:self.butMove];

        UIImageView * imageViewMove = [[UIImageView alloc]init];
        imageViewMove.image = [UIImage imageNamed:@"类别"];
        [self.butMove addSubview:imageViewMove];

        UIView * labelThread = [[UIView alloc]init];
        [self addSubview:labelThread];
        if (ScreenWidth == 320) {
            //5
            self.labelNumber.frame = CGRectMake(0,0,30,45);
            self.lableTitle.frame = CGRectMake(CGRectGetMaxX(self.labelNumber.frame),5.5, WidthScal750(480), 15);
            self.labelIntroduce.frame = CGRectMake(CGRectGetMaxX(self.labelNumber.frame), CGRectGetMaxY(self.lableTitle.frame)+3, WidthScal750(480), 14);
            self.imageViewHeadset.frame = CGRectMake(CGRectGetMaxX(self.labelIntroduce.frame)+5, CGRectGetMaxY(self.lableTitle.frame)+3,14,14);
            self.labelPlaysNumber.frame = CGRectMake(CGRectGetMaxX(self.imageViewHeadset.frame)+2, CGRectGetMaxY(self.lableTitle.frame)+3, ScreenWidth-CGRectGetMaxX(self.imageViewHeadset.frame)-60, 14);
            self.butMove.frame = CGRectMake(ScreenWidth-60, 0, 50, 45);
            imageViewMove.frame =  CGRectMake(0,(self.butMove.frame.size.height-20)/2, 20, 20);
            labelThread.backgroundColor = RGBColor(211, 211, 211);
            labelThread.frame = CGRectMake(20, 44.7, ScreenWidth-40, 0.3);
        }else if(ScreenWidth == 375){
            // 6 7
            self.labelNumber.frame = CGRectMake(0,0,30,50);
            self.lableTitle.frame = CGRectMake(CGRectGetMaxX(self.labelNumber.frame),8.5, WidthScal750(480), 16);
            self.labelIntroduce.frame = CGRectMake(CGRectGetMaxX(self.labelNumber.frame), CGRectGetMaxY(self.lableTitle.frame)+3, WidthScal750(480), 15);
            self.imageViewHeadset.frame = CGRectMake(CGRectGetMaxX(self.labelIntroduce.frame)+5, CGRectGetMaxY(self.lableTitle.frame)+3,15,15);
            self.labelPlaysNumber.frame = CGRectMake(CGRectGetMaxX(self.imageViewHeadset.frame)+2, CGRectGetMaxY(self.lableTitle.frame)+3, ScreenWidth-CGRectGetMaxX(self.imageViewHeadset.frame)-60, 15);
            self.butMove.frame = CGRectMake(ScreenWidth-60, 0,50, 50);
            imageViewMove.frame =  CGRectMake(0,(self.butMove.frame.size.height-20.5)/2, 20.5, 20.5);
            labelThread.backgroundColor = divider;
            labelThread.frame = CGRectMake(20, 49.7, ScreenWidth-40, 0.3);
        }else {
            //plus
            self.labelNumber.frame = CGRectMake(0,0,30,58);
            self.lableTitle.frame = CGRectMake(CGRectGetMaxX(self.labelNumber.frame),10.5, WidthScal750(480), 18);
            self.labelIntroduce.frame = CGRectMake(CGRectGetMaxX(self.labelNumber.frame), CGRectGetMaxY(self.lableTitle.frame)+3, WidthScal750(480), 16);
            self.imageViewHeadset.frame = CGRectMake(CGRectGetMaxX(self.labelIntroduce.frame)+5, CGRectGetMaxY(self.lableTitle.frame)+3,16,16);
            self.labelPlaysNumber.frame = CGRectMake(CGRectGetMaxX(self.imageViewHeadset.frame)+2, CGRectGetMaxY(self.lableTitle.frame)+3, ScreenWidth-CGRectGetMaxX(self.imageViewHeadset.frame)-60, 17);
            self.butMove.frame = CGRectMake(ScreenWidth-60, 0,50, 58);
            imageViewMove.frame =  CGRectMake(0,(self.butMove.frame.size.height-21)/2, 21, 21);
            labelThread.backgroundColor = divider;
            labelThread.frame = CGRectMake(20, 57.7, ScreenWidth-40, 0.3);
        }
//        [self createIndicatorView:self];
        // 1. 安装播放状态发生变化的通知
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(musicPlayerStatusDidChangedNotification:) name:LCMusicPlayerStatusDidChangedNotification object:_LCPlayer];
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(lcApplicationEnterForeground) name:UIApplicationWillEnterForegroundNotification object:nil];
//        // 2. 安装播放歌曲发生变化的通知
//        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(musicPlayerPlayingSongDidChangedNotification:) name:LCMusicPlayerPlayingSongDidChangedNotification object:_LCPlayer];
    }
    return self;
}
#pragma mark - 改变字体的颜色
- (void)didSelectRowCellWithIsSystemRed:(BOOL)isSystemRed
{
    if (isSystemRed) {
        self.labelNumber.textColor= RGBColor(238, 82, 74);
        self.lableTitle.textColor  = RGBColor(238, 82, 74);
        self.labelIntroduce.textColor= RGBColor(238, 82, 74);
        self.labelPlaysNumber.textColor = RGBColor(238, 82, 74);
        self.imageViewHeadset.image = [UIImage imageNamed:@"耳机_红"];
    }else{
        self.labelNumber.textColor= titleColorLSZ;
        self.lableTitle.textColor  = titleColorLSZ;
        self.labelIntroduce.textColor= lightColor;
        self.labelPlaysNumber.textColor = lightColor;
        self.imageViewHeadset.image = [UIImage imageNamed:@"耳机_次数"];
    }
}
/*
 - (void)dealloc {
 [[NSNotificationCenter defaultCenter] removeObserver:self];
 }
 ///MARK:- 播放状态小图标
 - (void)createIndicatorView:(UIView *)view {
 MusicIndicator *indicator = [MusicIndicator new];
 indicator.frame = CGRectMake([[UIScreen mainScreen]bounds].size.width - 125, 0, 50, 44);
 self.indicator = indicator;
 self.indicator.state = _LCPlayer.kstatus;
 indicator.hidesWhenStopped = NO;
 indicator.tintColor = [UIColor redColor];
 [view addSubview:indicator];
 UITapGestureRecognizer *tapInditator = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleTapIndicator)];
 tapInditator.numberOfTapsRequired = 1;
 [indicator addGestureRecognizer:tapInditator];

 [indicator mas_makeConstraints:^(MASConstraintMaker *make) {
 make.centerY.equalTo(self.mas_centerY);
 make.right.equalTo(self.mas_right).offset(-40);
 make.size.mas_equalTo(indicator.size);
 }];
 }
- (void)handleTapIndicator {
}
//MARK:-
#pragma mark - 通知处理回调
- (void)musicPlayerStatusDidChangedNotification:(NSNotification *)notification {
    // 获取当前播放状态
    LCMusicPlayerStatus kstatus = [notification.userInfo[kMusicPlayerStatus] integerValue];
    self.indicator.state = kstatus;
    if ([self.lableTitle.text isEqualToString:_LCPlayer.playingSong.title]) {
        self.indicator.hidden = NO;
    }else{
        self.indicator.hidden = YES;
    }
    NSLog(@"self.indicator.state = %zd", self.indicator.state);
}
- (void)musicPlayerPlayingSongDidChangedNotification:(NSNotification *)notification {
    JKSongsMessStatus *playingSong = notification.userInfo[kMusicPlayerPlayingSong];
    if ([self.lableTitle.text isEqualToString:playingSong.title]) {
        self.indicator.hidden = NO;
    }else{
        self.indicator.hidden = YES;
    }
}

- (void)lcApplicationEnterForeground {
    if ([self.lableTitle.text isEqualToString:_LCPlayer.playingSong.title]) {
        self.indicator.state = _LCPlayer.kstatus;
        self.indicator.hidden = NO;
    }else{
        self.indicator.hidden = YES;
    }
}
*/


@end
